package com.leyou.controller;

import com.leyou.common.pojo.ResultInfo;
import com.leyou.service.UploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

@Controller
@RequestMapping("/upload")
public class UploadFileController {

    @Autowired
    private UploadService uploadService;

    @PostMapping("/image")
    @ResponseBody
    public ResultInfo uploadImage(@RequestParam("file")MultipartFile file) throws Exception {
        String path = this.uploadService.upload(file);
        return ResultInfo.success(path);
    }
}
